<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>bformdec1</title>
    <link rel="stylesheet" type="text/css" href="csound.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.78.1" />
    <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" />
    <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="bformenc1.html" title="bformenc1" />
    <link rel="next" href="binit.html" title="binit" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">bformdec1</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="bformenc1.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="binit.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry">
      <a id="bformdec1"></a>
      <div class="titlepage"></div>
      <a id="IndexBformdec1" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">bformdec1</span>
        </h2>
        <p>bformdec1 — 
      Decodes an ambisonic B format signal
          </p>
      </div>
      <div class="refsect1">
        <a id="idp92006736"></a>
        <h2>Description</h2>
        <p>
    	Decodes an ambisonic B format signal into loudspeaker specific signals. 
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92008160"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ao1, ao2 <span class="command"><strong>bformdec1</strong></span> isetup, aw, ax, ay, az [, ar, as, at, au, av \
      [, abk, al, am, an, ao, ap, aq]]</pre>
        <pre class="synopsis">ao1, ao2, ao3, ao4 <span class="command"><strong>bformdec1</strong></span> isetup, aw, ax, ay, az [, ar, as, at, \
      au, av [, abk, al, am, an, ao, ap, aq]]</pre>
        <pre class="synopsis">ao1, ao2, ao3, ao4, ao5 <span class="command"><strong>bformdec1</strong></span> isetup, aw, ax, ay, az [, ar, as, \
      at, au, av [, abk, al, am, an, ao, ap, aq]]</pre>
        <pre class="synopsis">ao1, ao2, ao3, ao4, ao5, ao6, ao7, ao8 <span class="command"><strong>bformdec1</strong></span> isetup, aw, ax, ay, az \
      [, ar, as, at, au, av [, abk, al, am, an, ao, ap,
    aq]]]</pre>
        <pre class="synopsis">aout[] <span class="command"><strong>bformdec1</strong></span> isetup, abform[]</pre>
      </div>
      <div class="refsect1">
        <a id="idp92083680"></a>
        <h2>Initialization</h2>
        <p>
      Note that horizontal angles are measured anticlockwise in this
      description.
    </p>
        <p>
      <span class="emphasis"><em>isetup</em></span> –- loudspeaker setup. There are
      five supported setups: 
      </p>
        <div class="itemizedlist">
          <ul class="itemizedlist" style="list-style-type: disc; ">
            <li class="listitem">1.  Stereo - L(90), R(-90); this is an M+S style stereo decode.</li>
            <li class="listitem">2.	Quad - FL(45), BL(135), BR(-135), FR(-45). 
          This is a first-order `in-phase' decode.</li>
            <li class="listitem">3.	5.0 - L(30),R(-30),C(0),BL(110),BR(-110).
          Note that many people do not actually use the angles above for
          their speaker arrays and a good decode for DVD etc can be
          achieved using the Quad configuration to feed L, R, BL and BR
          (leaving C silent).</li>
            <li class="listitem">4.	Octagon - FFL(22.5),FLL(67.5),BLL(112.5),BBL(157.5),BBR(-157.5),BRR(-112.5),FRR(-67.5),FFR(-22.5).
          This is a first-, second- or third-order `in-phase' decode,
          depending on the number of input channels.</li>
            <li class="listitem">5.	Cube - FLD(45,-35.26),FLU(45,35.26),BLD(135,-35.26),BLU(135,35.26),BRD(-135,-35.26),BRU(-135,35.26),FRD(-45,-35.26),FRU(-45,35.26).
          This is a first-order `in-phase' decode.</li>
          </ul>
        </div>
        <p>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92089984"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>aw, ax, ay, ... </em></span>
      -- input signal in the B format.
    </p>
        <p>
      <span class="emphasis"><em>ao1 .. ao8</em></span> -– loudspeaker specific output signals.
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92092736"></a>
        <h2>Example</h2>
        <p>
      Here is an example of the bformdec1 opcode. It uses the file <a class="ulink" href="examples/bformenc1.csd" target="_top"><em class="citetitle">bformenc1.csd</em></a>.

    </p>
        <div class="example">
          <a id="idp92094592"></a>
          <p class="title">
            <strong>Example 88. Example of the bformdec1 opcode.</strong>
          </p>
          <div class="example-contents">
            <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p>
            <pre class="programlisting">
<span class="csdtag">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</span>
<span class="comment">; Select audio/midi flags here according to platform</span>
<span class="comment">; Audio out   Audio in    No messages</span>
<span class="comment">;-odac           -iadc     -d     ;;;RT audio I/O</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
 -o bformenc.wav -W <span class="comment">;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</span>
<span class="ohdr">sr</span> <span class="op">=</span> 44100
<span class="ohdr">ksmps</span> <span class="op">=</span> 32
<span class="ohdr">nchnls</span> <span class="op">=</span> 8
<span class="ohdr">0dbfs</span> <span class="op">=</span> 1

<span class="oblock">instr</span> 1 <span class="comment">;without arrays</span>
<span class="comment">; generate pink noise</span>
anoise <span class="opc">pinkish</span> 1
        
<span class="comment">; two full turns</span>
kalpha <span class="opc">line</span> 0, p3, 720
kbeta <span class="op">=</span> 0
        
<span class="comment">; generate B format</span>
aw, ax, ay, az, ar, as, at, au, av <span class="opc">bformenc1</span> anoise, kalpha, kbeta
        
<span class="comment">; decode B format for 8 channel circle loudspeaker setup</span>
a1, a2, a3, a4, a5, a6, a7, a8 <span class="opc">bformdec1</span> 4, aw, ax, ay, az, ar, as, at, au, av        

<span class="comment">; write audio out</span>
<span class="opc">outo</span> a1, a2, a3, a4, a5, a6, a7, a8
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2 <span class="comment">;with arrays (csound6)</span>
<span class="comment">;set file names for:</span>
S_bform <span class="op">=</span> "bform_out.wav" <span class="comment">;b-format (2nd order) output</span>
S_sound <span class="op">=</span> "sound_out.wav" <span class="comment">;sound output</span>

<span class="comment">; generate pink noise</span>
anoise <span class="opc">pinkish</span> 1
        
<span class="comment">; two full turns</span>
kalpha <span class="opc">line</span> 0, p3, 720
kbeta <span class="op">=</span> 0
        
<span class="comment">;create array for B-format 2nd order (9 chnls)</span>
aBform[] <span class="opc">init</span> 9

<span class="comment">; generate B-format</span>
aBform <span class="opc">bformenc1</span> anoise, kalpha, kbeta

<span class="comment">;write out b-format</span>
<span class="opc">fout</span> "fout.wav", 18, aBform

<span class="comment">;create array for audio output (8 channels)</span>
aAudio[] <span class="opc">init</span> 8
        
<span class="comment">;decode B format for 8 channel circle loudspeaker setup</span>
aAudio <span class="opc">bformdec1</span> 4, aBform

<span class="comment">; write audio out</span>
<span class="opc">fout</span> S_sound, 18, aAudio
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> 1 0 8
<span class="stamnt">i</span> 2 8 8
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92098944"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="bformenc1.html" title="bformenc1"><em class="citetitle">bformenc1</em></a>
    </p>
      </div>
      <div class="refsect1">
        <a id="idp92101056"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Richard Furse, Bruce Wiggins and Fons
          Adriaensen, following code by Samuel Groner</td>
          </tr>
          <tr>
            <td>2008</td>
          </tr>
        </table>
        <p>
    </p>
        <p>New in version 5.09</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="bformenc1.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="OpcodesTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="binit.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">bformenc1 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> binit</td>
        </tr>
      </table>
    </div>
  </body>
</html>
